package com.egg.ylt.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.egg.ylt.R;
import com.egg.ylt.Utils.Constants;
import com.egg.ylt.Utils.CustomUtils;
import com.egg.ylt.Utils.StatusBarUtil;
import com.egg.ylt.Utils.StringUtil;
import com.egg.ylt.presenter.impl.NewPhonePresenterImpl;
import com.egg.ylt.view.INewPhoneView;
import com.yonyou.framework.library.base.BaseActivity;
import com.yonyou.framework.library.bean.ErrorBean;
import com.yonyou.framework.library.common.utils.ToastUtil;

import butterknife.BindView;
import butterknife.OnClick;

public class ACT_FindPassword extends BaseActivity<NewPhonePresenterImpl> implements INewPhoneView {


    @BindView(R.id.include_iv_back)
    ImageView includeIvBack;
    @BindView(R.id.include_tv_title)
    TextView includeTvTitle;
    @BindView(R.id.include_tv_right)
    TextView includeTvRight;
    @BindView(R.id.include_rl_view)
    RelativeLayout includeRlView;
    @BindView(R.id.edit_phone_find)
    EditText editPhoneFind;
    @BindView(R.id.btn_next_find)
    TextView btnNextFind;

    public static int mType;
    private String mPhone;

    @Override
    protected void getBundleExtras(Bundle extras) {
        mType = extras.getInt("type");
    }

    @Override
    protected int getContentViewLayoutID() {
        return R.layout.act_find_password;
    }

    @Override
    protected View getLoadingTargetView() {
        return null;
    }

    @Override
    protected void initViewsAndEvents() {
        StatusBarUtil.setStatusBarColor(this, R.color.ylt_whit);
        StatusBarUtil.StatusBarLightMode(this);
        CustomUtils.setImmersiveStatusBar(mContext, includeRlView);
        includeTvTitle.setText("找回密码");
    }

    @Override
    protected boolean isApplyStatusBarTranslucency() {
        return false;
    }

    @Override
    protected boolean isBindEventBusHere() {
        return false;
    }

    @Override
    protected boolean toggleOverridePendingTransition() {
        return false;
    }

    @Override
    protected TransitionMode getOverridePendingTransitionMode() {
        return null;
    }

    @Override
    protected boolean isApplyKitKatTranslucency() {
        return false;
    }

    @Override
    public void showBusinessError(ErrorBean error) {

    }

    @OnClick({R.id.include_iv_back, R.id.btn_next_find})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.include_iv_back://返回键
                finish();
                break;
            case R.id.btn_next_find://下一步
                mPhone = editPhoneFind.getText().toString();
                if (!StringUtil.isPhone(mPhone)) {
                    ToastUtil.makeText(mContext, "手机号不正确", false);
                    return;
                }
                mPresenter.checkedPhone(mPhone, Constants.COMPANYID, "1");
                break;
        }
    }

    @Override
    public void saveNewPhone() {

    }

    @Override
    public void getPhoneCode() {
        Bundle mBundle = new Bundle();
        mBundle.putString("phone", mPhone);
        mBundle.putInt("type", Constants.FIND_PASSWORD_TO_CODE);
        readyGo(ACT_ImportCode.class, mBundle);
    }
}
